package com.hk.core.data.r2dbc.tenants;

import com.hk.commons.util.StringUtils;
import reactor.core.publisher.Mono;

/**
 * @author Kevin
 * @date 2024-04-21 09:36
 * @see com.hk.commons.multischema.DataSourceType
 */
public interface ReactiveTenantIdResolver {

    Mono<String> resolve(String value);

    static ReactiveTenantIdResolver fixed() {
        return value -> (StringUtils.startsWith("${", value) || StringUtils.startsWith("#{", value)) &&
                StringUtils.endsWith("}", value) ? Mono.empty() : Mono.justOrEmpty(value);
    }
}
